package actions;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.User;
import beans.UserDAO;

public class UserActionModifyTjAjax implements UserAction {

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException {
		
		System.out.println("进入UserActionModifyTjAjax");
		
		boolean flag;
		UserDAO userdao=new UserDAO();			
		flag=userdao.updatephotoAjax(request);
		//flag=update(request);结果证明使用requst来接，没有乱码
		if(flag){
			response.getWriter().println("更新成功");
			
		}else{
			response.getWriter().println("更新失败");
		}
	}
	
	public boolean update(HttpServletRequest request)throws IOException{
		//接其他参数
		System.out.println("***********测试接到的数据是否是乱码,结果证明使用requst来接，没有乱码**************");
		String userpwd = request.getParameter("userpwd");
		String username = request.getParameter("username");//username=new String(username.getBytes("ISO8859-1"),"utf-8");//必须配合客户端的encodeURI(params);但我原来也没有做啊
		//new String(request.getParameter("data").getBytes("ISO8859-1"), "UTF-8");
		String usersex = request.getParameter("usersex");
		String userage = request.getParameter("userage");
		String useraddress = request.getParameter("useraddress");
		String userprofession = request.getParameter("userprofession");
		String useremail = request.getParameter("useremail");
		//String userphoto = userno+"."+suffix;
		String usersummary = request.getParameter("usersummary");		
		String userinterest = request.getParameter("userinterest");
		System.out.println("username:"+username);
		System.out.println("useraddress:"+useraddress);
		System.out.println("userinterest:"+userinterest);
		return true;
	}

}
